/*
 * This file is part of aion-engine <aion-engine.com>
 *
 * aion-engine is private software: you can redistribute it and or modify
 * it under the terms of the GNU Lesser Public License as published by
 * the Private Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * aion-engine is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser Public License for more details.
 *
 * You should have received a copy of the GNU Lesser Public License
 * along with aion-engine.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.aionengine.gameserver.network.aion.serverpackets;

import com.aionengine.gameserver.model.town.Town;
import com.aionengine.gameserver.network.aion.AionConnection;
import com.aionengine.gameserver.network.aion.AionServerPacket;

import java.util.Map;


/**
 * @author ViAl
 */
public class SM_TOWNS_LIST extends AionServerPacket {

    private Map<Integer, Town> towns;

    public SM_TOWNS_LIST(Map<Integer, Town> towns) {
        this.towns = towns;
    }

    protected void writeImpl(AionConnection con) {
        writeH(towns.size());
        for (Town town : towns.values()) {
            writeD(town.getId());
            writeD(town.getLevel());
            writeD((int) (town.getLevelUpDate().getTime() / 1000));
        }
    }
}
